package com.sskj.hhhjys;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.hhhjys.bean.Stock;
import com.sskj.hhhjys.http.HttpConfig;
import com.sskj.hhhjys.presenter.BasePresenter;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/05/10
 */
class ChartPresenter extends BasePresenter<ChartFragment> {

    /**
     * 获取股票K线 b
     *
     * @param goodsType K线周期(minute/minute5/minute15/minute30/minute60/day)
     * @param code      (BCH_USDT/ETC_USDT/ETH_USDT/BTC_USDT/LTC_USDT )

     */
    public void getStockInfo(String goodsType, String code) {
        OkGo.<HttpData<List<Stock>>>get(HttpConfig.BASE_URL + HttpConfig.GOODS_INFO)
                .params("goodsType", goodsType)
                .params("code", code)
                .execute(new JsonCallBack<HttpData<List<Stock>>>(this, false) {
                    @Override
                    public void onSuccess(Response<HttpData<List<Stock>>> response) {
                        List<Stock> stockList = response.body().getData();
                        mView.setChart(stockList);
                    }

                });
    }

}
